package com.edu.exam.entity.assessment.technical;

import com.edu.exam.enums.assessment.technical.PaperCheckRuleType;
import com.edu.exam.enums.assessment.technical.PaperCheckAlgorithm;
import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 试卷查重规则配置实体类
 * 所属模块：B-02 题库管理模块
 * 对应数据库表：paper_check_rule
 *
 * 用于配置试卷查重的规则参数，包括相似度阈值、查重策略、忽略内容等。
 *
 * @author System
 * @version 1.0.0
 */

@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class PaperCheckRule {

    /**
     * 主键ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 规则名称
     */
    @Column(name = "rule_name", nullable = false, length = 100)
    private String ruleName;

    /**
     * 规则描述
     */
    @Column(name = "rule_description", length = 500)
    private String ruleDescription;

    /**
     * 规则类型
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "rule_type", nullable = false, length = 20)
    private PaperCheckRuleType ruleType;

    /**
     * 相似度阈值（百分比）
     */
    @Column(name = "similarity_threshold", nullable = false)
    private Integer similarityThreshold;

    /**
     * 最小匹配字符数
     */
    @Column(name = "min_match_chars")
    private Integer minMatchChars;

    /**
     * 最大匹配字符数
     */
    @Column(name = "max_match_chars")
    private Integer maxMatchChars;

    /**
     * 是否忽略标点符号
     */
    @Column(name = "ignore_punctuation", nullable = false)
    private Boolean ignorePunctuation = true;

    /**
     * 是否忽略空白字符
     */
    @Column(name = "ignore_whitespace", nullable = false)
    private Boolean ignoreWhitespace = true;

    /**
     * 是否忽略大小写
     */
    @Column(name = "ignore_case", nullable = false)
    private Boolean ignoreCase = true;

    /**
     * 是否启用同义词匹配
     */
    @Column(name = "enable_synonym_match", nullable = false)
    private Boolean enableSynonymMatch = false;

    /**
     * 是否启用语义匹配
     */
    @Column(name = "enable_semantic_match", nullable = false)
    private Boolean enableSemanticMatch = false;

    /**
     * 查重算法
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "check_algorithm", nullable = false, length = 30)
    private PaperCheckAlgorithm checkAlgorithm;

    /**
     * 权重配置
     */
    @Column(name = "weight_config", columnDefinition = "TEXT")
    private String weightConfig;

    /**
     * 规则优先级
     */
    @Column(name = "rule_priority")
    private Integer rulePriority = 0;

    /**
     * 是否启用
     */
    @Column(name = "is_active", nullable = false)
    private Boolean isActive = true;

    /**
     * 是否系统默认规则
     */
    @Column(name = "is_system_default", nullable = false)
    private Boolean isSystemDefault = false;

    /**
     * 使用次数
     */
    @Column(name = "usage_count", nullable = false)
    private Long usageCount = 0L;

    /**
     * 创建者ID
     */
    @Column(name = "creator_id")
    private Long creatorId;

    /**
     * 创建者姓名
     */
    @Column(name = "creator_name", length = 50)
    private String creatorName;

    /**
     * 创建时间
     */
    @Column(name = "created_time", nullable = false)
    private LocalDateTime createdTime;

    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    private LocalDateTime updatedTime;

    /**
     * 版本号（用于乐观锁）
     */
    @Version
    @Column(name = "version", nullable = false)
    private Long version;

    /**
     * 是否删除
     */
    @Column(name = "is_deleted", nullable = false)
    private Boolean isDeleted = false;

    /**
     * 删除时间
     */
    @Column(name = "deleted_time")
    private LocalDateTime deletedTime;

    /**
     * 删除者ID
     */
    @Column(name = "deleter_id")
    private Long deleterId;

  }